package com.potenza.training.dictionary.server.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.potenza.training.dictionary.dao.HopeMinSalaryDao;
import com.potenza.training.dictionary.entity.HopeMinSalary;
import com.potenza.training.dictionary.server.HopeMinSalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("hopeMinSalaryServiceImpl")
public class HopeMinSalaryServiceImpl extends ServiceImpl<HopeMinSalaryDao, HopeMinSalary> implements HopeMinSalaryService {

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public List<HopeMinSalary> findAll() {
        Object minSalary = redisTemplate.opsForValue().get("minSalary");
        if (minSalary==null){
            List<HopeMinSalary> list = this.list();
            redisTemplate.opsForValue().set("minSalary", list);
            return list;
        }
        return (List<HopeMinSalary>)minSalary;
    }
}